package edu.hunau.cxb19.oop.class09.sort;

/**
 *  通过实现Comaparable接口为类提供默认的排序规则
 * @author hb
 *
 *         2020-03-05 15:54:51
 */
public class Student implements Comparable<Student> {
	private int id;
	private String name;

	/**
	 * 默认排序规则：根据学生的学号进行排序
	 */
	public int compareTo(Student o) {
		return o.id-this.id;
	}

	/**
	 * @param id
	 * @param name
	 */
	public Student(int id, String name) {
		super();
		this.id = id;
		this.name = name;
	}

	@Override
	public String toString() {
		return "Student [id=" + id + ", name=" + name + "]";
	}

	/**
	 * 
	 */
	public Student() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

}
